// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import {getStorage} from "./common/js/localStorage";
//全局引入Element-ui
import Element from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

//全局引入echarts
import echarts from 'echarts'

Vue.prototype.$echarts = echarts


Vue.config.productionTip = false

Vue.use(Element)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
//判断登录状态如果localStorage中的user信息不存在则跳转到登录路由
router.beforeEach((to,from,next)=>{
    if(to.path==='/Login'){
      next()
    }else {
      if(!getStorage('user')){
        next({'name':'Login'})
      }else {
        next();
      }
    }
})

